/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pedagio.util;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Window;
import javax.swing.JDialog;

/**
 *
 * @author pedroo
 */
public class JanelasUtil {

    private JanelasUtil() {
    }

    public static void exibirJanela(JDialog dialog) {
        centerAndShow(dialog);
    }
    
    public static void exibirJanelaMaximizada(JDialog dialog) {
        dialog.setSize(dialog.getParent().getSize());
        
        //            Dimension d = this.getSize();
//            d.height = d.height - (3*this.menuBar.getSize().height) - (this.panelTarefa.getSize().height);
//            formulario.setSize(d);
//            formulario.setLocation(this.getLocation().x, this.getLocation().y + this.menuBar.getSize().height + this.panelTarefa.getSize().height) ;
//            formulario.setVisible(true);
    }
    
    public static void centerAndShow(Window aWindow) {

        aWindow.pack();
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension window = aWindow.getSize();
        


        if (window.height > screen.height) {
            window.height = screen.height;
        }
        if (window.width > screen.width) {
            window.width = screen.width;
        }
        
        int xCoord = (screen.width / 2 - window.width / 2);
        int yCoord = (screen.height / 2 - window.height / 2);
        aWindow.setLocation(xCoord, yCoord);

        aWindow.setVisible(true);
    }
}